import 'package:flutter/material.dart';

import 'WeChatsPage.dart';
import 'ContactsPage.dart';
import 'DiscoverPage.dart';
import 'MePage.dart';

void main() => runApp(new WeChatApp());

class WeChatApp extends StatelessWidget {
	@override
	Widget build(BuildContext context) {
		return MaterialApp(
			title: "Flutter WeChat Demo",
			home: WeChatHomePage(title: 'Flutter WeChat Demo',),
		);
	}
}

class WeChatHomePage extends StatefulWidget {
	final String title;
	
	WeChatHomePage({Key key, this.title}) : super(key: key);

	@override
	_WeChatHomePageState createState() => _WeChatHomePageState();
}

class _WeChatHomePageState extends State<WeChatHomePage> with SingleTickerProviderStateMixin {
	final List<Tab> _bootomTabs = <Tab>[
		new Tab(text: 'Chats', icon: Icon(Icons.chat),),
		new Tab(text: 'Contacts', icon: Icon(Icons.contacts),),
		new Tab(text: 'Discover', icon: Icon(Icons.devices_other),),
		new Tab(text: 'Me', icon: Icon(Icons.verified_user),)
	];
	TabController _tabController = null;

	@override
	void initState() {
		super.initState();
		_tabController = new TabController(
			vsync: this,
			length: _bootomTabs.length
		);
	}

	@override
	void dispose() {
		_tabController.dispose();
		super.dispose();
	}

	@override
	Widget build(BuildContext context) {
		return Scaffold(
			body: TabBarView(
				controller: _tabController,
				children: <Widget>[
					WeChatsPage(title: 'Chats',),
					ConcatsPage(title: 'Concats',),
					DiscoverPage(title: 'Discover',),
					MePage(title: 'Me',)
				],
			),
			bottomNavigationBar: Material(
				color: Colors.deepOrange,
				child: TabBar(
					controller: _tabController,
					tabs: _bootomTabs,
					indicatorColor: Colors.white,
				),
			),
		);
	}
}